package com.todo.delicacy.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.delicacy.application.backend.service.FoodInfoBackendService;
import com.todo.delicacy.iface.backend.FoodInfoBackendIface;
import com.todo.delicacy.iface.backend.request.*;
import com.todo.delicacy.iface.backend.response.BaseFoodInfoResp;
import com.todo.delicacy.iface.backend.response.QueryRestaurantInfoByConditionRsp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/6/7 15:43
 * @description
 */
@RestController
@RequestMapping("/bd/food")
@Tag(name = "美食后台处理类", description = "美食后台处理类")
public class FoodInfoBackendController implements FoodInfoBackendIface {

    @Resource
    private FoodInfoBackendService foodInfoBackendService;


    @Override
    @Operation(summary = "根据id查询美食")
    @PostMapping("/queryFoodInfoById")
    public BizResponse<BaseFoodInfoResp> queryFoodInfoById(@RequestBody QueryFoodInfoByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return foodInfoBackendService.queryFoodInfoById(req);
    }

    @Override
    @Operation(summary = "多条件查询美食列表")
    @PostMapping("/queryFoodInfoByCondition")
    public BizPageResponse<QueryRestaurantInfoByConditionRsp> queryFoodInfoByCondition(@RequestBody QueryFoodInfoByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return foodInfoBackendService.queryFoodInfoByCondition(req);
    }

    @Override
    @Operation(summary = "更新美食信息")
    @PostMapping("/updateFoodInfo")
    public BizResponse<Boolean> updateFoodInfo(@RequestBody UpdateFoodInfoReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return foodInfoBackendService.updateFoodInfo(req);
    }

    @Override
    @Operation(summary = "新增美食信息")
    @PostMapping("/insertFoodInfo")
    public BizResponse<Boolean> insertFoodInfo(@RequestBody InsertFoodInfoReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return foodInfoBackendService.insertFoodInfo(req);
    }

    @Override
    @Operation(summary = "启禁用美食信息")
    @PostMapping("/enableFoodInfo")
    public BizResponse<Boolean> removeFoodInfoById(@RequestBody RemoveFoodInfoReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return foodInfoBackendService.removeFoodInfoById(req);
    }
}
